package com.example.voicedet;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;

public class AlarmActivity extends Activity {
	MediaPlayer alarmMusic;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		//加载指定对象，并为之创建MediaPlayer对象。
		Log.d("alarm","5678");
		Intent intent = getIntent();
		//Bundle content = intent.getExtras();
		String content1 =intent.getStringExtra("content");
		alarmMusic = MediaPlayer.create(this, R.raw.paomo);
		alarmMusic.setLooping(true);
		//播放音乐
		alarmMusic.start();
		//创建一个对话框
		new AlertDialog.Builder(AlarmActivity.this).setTitle("闹钟")
		.setMessage(content1)
		.setPositiveButton("确定",new OnClickListener()
		{
			public void onClick(DialogInterface dialog,int which){
				//停止音乐
				alarmMusic.stop();
				//结束该Activity
				AlarmActivity.this.finish();
			}
		}).show();
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.alarm, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();
		if (id == R.id.action_settings) {
			return true;
		}
		return super.onOptionsItemSelected(item);
	}
}
